﻿// StopReminderCommand.cs
using System.Drawing;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell;


using VSIXProjectGit;
using VSIXProjectGit.Config;

[Command(PackageIds.StartReminderCommand)]
internal sealed class StartReminderCommand : BaseCommand<StartReminderCommand>
{
    protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
    {
        await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
#if DEBUG
        //System.Diagnostics.Debugger.Break(); // 强制断点
#endif
        ReminderService.Instance.Start();
        await VS.StatusBar.ShowMessageAsync("喝水提醒已启动！！！"); 
    }
}






namespace VSIXProjectGit
{
    [Command(PackageIds.StopReminderCommand)]
    internal sealed class StopReminderCommand : BaseCommand<StopReminderCommand>
    {
        protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            ReminderService.Instance.Stop();
            // 在需要调试的代码前添加（仅调试用）

            //await VS.MessageBox.ShowAsync("喝水提醒已关闭！");
            await VS.StatusBar.ShowMessageAsync("喝水提醒已关闭！");
        }
    }
}

// ConfigReminderCommand.cs

namespace VSIXProjectGit
{
    [Command(PackageIds.ConfigReminderCommand)]
    internal sealed class ConfigReminderCommand : BaseCommand<ConfigReminderCommand>
    {
        protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            try
            {
                var config = ReminderService.Instance.GetConfig();

                // 使用美观的配置窗体
                using (var form = new ConfigForm(config))
                {
                    // 设置窗体图标（如果有）
                    // form.Icon = Properties.Resources.AppIcon;

                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        ReminderService.Instance.UpdateConfig(form.GetConfig());
                        await VS.StatusBar.ShowMessageAsync("✅ 喝水提醒配置已保存！");
                    }
                }
            }
            catch (Exception ex)
            {
                await VS.MessageBox.ShowErrorAsync($"配置保存失败: {ex.Message}");
            }
        }
    }

}






















